import request from "../../request/request";

// 登录
export function Login(username, password) {
    console.log("Attempting login with:", username, password);
    return request({
        url: '/api/admin/user/login',
        method: 'get',
        params: {
            username,
            password
        }
    })
}

// 获取登录用户信息
export function GetUserinfo() {
    return request({
        url: '/admin/system/index/getUserInfo',
        method: 'get'
    });
}

// 退出功能
export function Logout() {
    return request({
        url: '/admin/system/index/logout',
        method: 'get'
    });
}


// 获取菜单
export function GetMenus() {
    return request({
        url: '/api/admin/menu/getMenu',
        method: 'get',
        headers: {
            'token': localStorage.getItem('token')
        }
    })
}

// 展示所有用户
export function adUserList(data) {
    return request({
        url: '/admin/user/adUserList',
        method: 'post',
        data
    })
}

// 修改用户状态
export function adUserStatus(id, status) {
    return request({
        url: '/admin/user/adUserStatus',
        method: 'post',
        params: {
            id: id,
            status: status
        }
    })
}

// 删除用户信息
export function adUserDelete(id) {
    return request({
        url: '/admin/user/adUserDelete',
        method: 'post',
        params: {
            id: id
        }
    })
}

// 添加或更新用户
export function adUserAddOrUpdate(data) {
    return request({
        url: '/admin/user/adUserAddOrUpdate',
        method: 'post',
        data
    })
}

// 退出登录
export function logout() {
    return request({
        url: '/adminUser/logout',
        method: 'post'
    })
}

// 更换头像
export function updateAvatar(data) {
    return request({
        url: '/user/updateAvatar',
        method: 'post',
        data
    })
}

//修改当前登录用户信息
export function updateUserInfo(data) {
    return request({
        url: '/user/updateUserInfo',
        method: 'post',
        data
    })
}

// 获取首页统计数据
export function getStatistics() {
    return request({
        url: '/statistics/overview',
        method: 'get'
    })
}

// 获取用户类型占比数据
export function getUserRatio() {
    return request({
        url: '/statistics/userRatio',
        method: 'get'
    })
}

// 获取用户增长数据
export function getUserGrowth() {
    return request({
        url: '/statistics/userGrowth',
        method: 'get'
    })
}
